#include "vga.h"
#include "stdio.h"
#include "asm.h"
#include "typedef.h"

u8 putc(u8 ch) {
  monitor_put(ch);
  return ch;
}

void kprintf(char* format, ...) {
  char* c;
  int n = 1;

  for(c = format; *c != '\0'; ++c) {
    if(*c == '%') {
      switch(*(++c)) {
        case 'x':
        case 'p':
	  monitor_write_hex(get_arg(n++));
	  break;
        case 'd':
	  monitor_write_dec(get_arg(n++));
	  break;
        case 'c':
	  monitor_put((char)get_arg(n++));
	  break;
        case 's':
	  monitor_write((char*)get_arg(n++));
	  break;
      }
    }

    else
      monitor_put(*c);
  }
}
